Public Partial Class wfrmCadInformativo
    Inherits System.Web.UI.Page
    Protected script As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnSalvar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalvar.Click
        Gravar()

    End Sub
    Private Sub MostraREgistro()
        Dim fun As New Funcoes
        Dim c As New SiteDLL.Informativo
        Try
            c.IDInformativo = Val(txtidInformativo.Text)
            c.carregar()
            If c.TemRegistro Then
                btnRemover.Enabled = True
                txtTitulo.Text = c.Titulo
                HtmlEditor1.InnerHTML = c.Conteudo
            Else
                btnRemover.Enabled = False
            End If

        Catch ex As Exception
            script += fun.MsgboxAviso(ex.Message)
        Finally
            c.Dispose()
            c = Nothing
            fun = Nothing

        End Try

    End Sub
    Private Sub Gravar()
        Dim fun As New Funcoes
        Dim c As New SiteDLL.Informativo
        Try
            c.IDInformativo = Val(txtidInformativo.Text)
            c.carregar()
            c.Titulo = Trim(txtTitulo.Text)
            c.Conteudo = HtmlEditor1.InnerHTML
            c.salvar()
            c.efetivarTransacao()
            script += fun.MsgboxAviso(c.Aviso, True)
        Catch ex As Exception
            script += fun.MsgboxAviso(ex.Message)
        Finally
            c.Dispose()
            c = Nothing
            fun = Nothing

        End Try

    End Sub
    Private Sub Remover()
        Dim fun As New Funcoes
        Dim c As New SiteDLL.Informativo
        Try
            c.IDInformativo = Val(txtidInformativo.Text)
            c.carregar()
            If c.TemRegistro Then
                c.excluir()
            End If
            c.efetivarTransacao()
            script += fun.MsgboxAviso(c.Aviso, True)
        Catch ex As Exception
            script += fun.MsgboxAviso(ex.Message)
        Finally
            c.Dispose()
            c = Nothing
            fun = Nothing

        End Try
    End Sub

    Protected Sub GRidInformativo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GRidInformativo.SelectedIndexChanged
        txtidInformativo.Text = GRidInformativo.SelectedRow.Cells(0).Text
        MostraREgistro()
    End Sub

    Protected Sub btnRemover_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemover.Click
        Remover()

    End Sub

    Protected Sub btnLimpar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLimpar.Click
        Response.Redirect(Request.Path)

    End Sub
End Class